package com.cp.controller;

import com.cp.service.EmailService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.File;

@Controller
public class EmailController {

    @Autowired
    private EmailService emailService;

    @ApiOperation(value = "邮件发送接口")
    @ResponseBody
    @RequestMapping(value = "/stringEmaile",method = RequestMethod.GET)
    public String sendStringEmail(){
        emailService.sendStringEmail("2138942661@qq.com","你好","我发的你收到了吗？");
        return "发送成功";
    }

    @ResponseBody
    @RequestMapping(value = "/bigEmaile",method = RequestMethod.GET)
    public String sendBigEmail(){
        File file = new File("src/main/resources/static/zong.jpg");
        emailService.sendBigEmail("mmmmmm@qq.com","你好，美图请查收","看我拍的咋样？",file);
        return "发送成功";
    }

    @ResponseBody
    @RequestMapping(value = "/templateEmail",method = RequestMethod.GET)
    public String sendTemplateEmail(){
        //emailService.sendTemplateEmail("mmmmmm@qq.com","激活邮件","freemarkerTemplate.html");
        emailService.sendTemplateEmail("mmmmmm@qq.com","激活邮件","thymeleafTemplate.html");
        return "发送成功";
    }
}
